/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package flight.server;

import java.util.HashMap;
import java.util.List;
import java.util.TimerTask;
import middleware.Callback;

/**
 *
 * @author VU MINH TAM
 * TimerTask to deregister callback object after interval
 */
public class DeregisterCallbackTask extends TimerTask{
    List<Callback> callbackList;
    int id;
    String ipToRemove;

    public DeregisterCallbackTask(int flightId, String ip, List<Callback> cbList){
        callbackList = cbList;
        id = flightId;
        ipToRemove = ip;
    }
    @Override
    /*
     * 
     */
    public void run() {

        synchronized(callbackList){
            for(Callback c: callbackList){
                if(c.getIp().equals(ipToRemove)){
                    callbackList.remove(c);
                    System.out.println("Deregister call back for ip " + ipToRemove);
                    break;
                }
            }
        }

    }

}
